<extend name="Public/base" />
	<block name='body'>
		<section class="content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title">增加分类</h3>
                        </div>
                        <!-- /.box-header -->
                        <form action="{:U('Shop/addEditCategory?is_ajax=1')}" method="post" class="form-horizontal" id="category_form">
                        <div class="box-body">     
                            <div class="form-item cf">
                                <label class="item-label">分类名称<span class="check-tips">（输入分类名称）</span></label>
                                <div class="controls">
                                    <input type="text" placeholder="名称" class="text input-large" name="name" value="{$goods_category_info.name}">
                                </div>
                            </div>
                             <div class="form-item cf">
                                <label class="item-label">上级分类<span class="check-tips">（选择上级分类）</span></label>
                                <div class="controls fl">
                                    <select name="parent_id_1" id="parent_id_1" onchange="get_category(this.value,'parent_id_2','0');" >
                                            <option value="0">顶级分类</option>
                                            <foreach name="cat_list" item="v" >                                            
                                                <option value="{$v[id]}">{$v[name]}</option>
                                            </foreach>                                            
                                    </select>
                                </div>
                                <div class="controls fl">
                                     <select name="parent_id_2" id="parent_id_2"  class="small form-control">
                                        <option value="0">请选择商品分类</option>
                                      </select>  
                                </div>
                            </div>
                             <div class="form-item cf">
                                <label class="item-label">排序<span class="check-tips">（输入排序）</span></label>
                                <div class="controls">
                                    <input type="text" placeholder="50"  class="text input-small"  name="sort_order" value="{$goods_category_info.sort_order}"/>
                                </div>
                            </div>
                            <style type="text/css">table{text-align: center;}</style>
                            <div class="form-item cf">
                                        <table border="1">
                                    <thead>
                                        <tr>
                                            <td>是否显示</td>
                                            <td>是否热销</td>
                                            <td>是否参与机考</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>
                                                <input type="checkbox" name="is_show" value="1" <eq name='goods_category_info.is_show' value='1'>checked</eq> >
                                            </td>
                                            <td>
                                                <input type="checkbox" name="is_hot" value="1" <eq name='goods_category_info.is_hot' value='1'>checked</eq> >
                                            </td>
                                            <td>
                                                <input type="checkbox" name="is_test" value="1" <eq name='goods_category_info.is_test' value='1'>checked</eq> >
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                       
                            <div style="margin-top: 10px;">
                                <notempty name='Think.get.id'>
                                    <input type="hidden" name='id' value='{$Think.get.id}'>
                                </notempty>
                                <button type="submit" class="btn submit-btn ajax-post" target-form="form-horizontal">确 定</button>
                                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </section>
	</block>
    <block name="script">
        <script type="text/javascript">
            highlight_subnav('{:U('Shop/Category')}');
            $(document).ready(function(){
            <if condition="$level_cat['2'] gt 0">   
                 // 如果当前是二级分类就让一级父id默认选中
                 $("#parent_id_1").val('{$level_cat[1]}'); 
                 get_category('{$level_cat[1]}','parent_id_2','0');      
            </if>    
            <if condition="$level_cat['3'] gt 0">
                 // 如果当前是三级分类就一级和二级父id默认 都选中
                 $("#parent_id_1").val('{$level_cat[1]}');          
                 get_category('{$level_cat[1]}','parent_id_2','{$level_cat[2]}');   
            </if>   
        });
        </script>
    </block>w